﻿using System;
using System.Collections;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Converters;

namespace Charts.Converters
{
	public class YValueAxisItemsConverter : MultiValueConverterBase<YValueAxisItemsConverter>
	{
		public override object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			try {
				
				double min = (double)values[0];
				double max = (double)values[1];
				int count = (int)values[2];
				
				double step = (max - min) / ((double)count - 1);
				
				return Enumerable
					.Range(0, count)
					.Select(i => min + ((double)i) * step)
					.ToArray();

			} catch (Exception) {
				return DependencyProperty.UnsetValue;
			}
		}
	}
}